<?php

// 数据库配置


session_start();

if (!isset($_SESSION['username'])) {
    header("Location: ../login.php");
    exit();
}

include 'config.php';
 // 如果

// 检查是否是 GET 请求
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    // 查询授权列表
    $query = "SELECT qq, lxqq, now_time, vip_time, ty FROM sq";
    $result = $conn->query($query);

    if ($result) {
        $auth_list = [];
        while ($row = $result->fetch_assoc()) {
            $auth_list[] = $row;
        }
        $response = [
            "code" => "200",
            "msg" => "获取授权列表成功",
            "data" => $auth_list
        ];
    } else {
        $response = [
            "code" => "500",
            "msg" => "查询失败",
            "error" => $conn->error
        ];
    }

    // 返回 JSON 响应
    
    echo json_encode($response, JSON_UNESCAPED_UNICODE);
} else {
    // 如果不是 GET 请求，返回错误
    header("HTTP/1.1 405 Method Not Allowed");
    exit("仅支持 GET 请求");
}

// 关闭数据库连接
$conn->close();
?>